import { getArraysByMaps } from '@/utils/getUtils';
const getSearchedOptionsByParseMaps = (list) => {
  return function ({ valueKey, labelKey, labelParentKey }) {
    let listByUuid = new Map();
    list.forEach(item => {
      listByUuid.set(item[valueKey], {
        value: item[valueKey],
        label: labelParentKey
          ? (item[labelParentKey] ? item[labelParentKey][labelKey] : '')
          : (item[labelKey])
      })
    });
    return getArraysByMaps(listByUuid);
  }
}

// 当前项是主供
const isMainSupplyByItem = (item) => {
  return item.isMainSupply === '1';
}
// 当前项不是主供
const isNotMainSupplyByItem = (item) => {
  return item.isMainSupply === '2';
}
export {
  getSearchedOptionsByParseMaps,
  isMainSupplyByItem,
  isNotMainSupplyByItem
}
